/* 
 * File:   mapdata.h
 * Author: cow
 *
 * Created on May 15, 2011, 9:01 PM
 */

#ifndef MAPDATA_H
#define	MAPDATA_H

//includes---------------------------------------
#include <fstream>
#include <map>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <typeinfo>
using namespace std;
//defines----------------------------------------
namespace mapdata{
#define fleetZ 1
#define planetZ 1
#define terrZ 0
enum tp_terr{
	space = 0,
	astr,
	neb,
	debris,
	TER_MAX
};
enum tp_res{
	metal = 0,
	chem,
	crew,
	salvo,
	fuel,
	RES_MAX
};
}
//prototypes-------------------------------------
namespace mapdata{
class placeable;
class moveable;
class terrain;
class maprep;
}
//definitions------------------------------------
namespace mapdata{
//placeable++++++++
class placeable{
public:
	//constructors------
	placeable(maprep* pmp);
	placeable(int x, int y, maprep* pmp);
	~placeable();
	//access------------
	int gX();
	int gY();
	int gZ();
	void gPos(int &x, int &y);
	void gPos(int &x, int &y, int &z);
	//manips------------
	virtual void setZ(int z);
	virtual bool place(int x, int y);
	virtual void remove();
protected:
	maprep* parent;
	int x, y, z;
};
//moveable+++++++++
class moveable : public placeable{
public:
	virtual void move(int x, int y) = 0;
};
//terrain++++++++++
class terrain : public placeable{
public:
	//constructors------
	terrain(tp_terr tp, maprep* mrep);
	terrain();
	~terrain();
	//access------------
	tp_terr gType();
	float gHazard();
	float gSensBlock();
	float gSpedBlock();
	int gResource(tp_res rtp);
	//manips------------
	void sType(tp_terr tp);
	void sHazard(float ft);
	void sSensBlock(float ft);
	void sSpedBlock(float ft);
	void rResource(tp_res rtp, int rp);
	void sResource(tp_res rtp, int rp);
private:
	tp_terr type;
	float hazard;
	float sensorBlock;
	float speedBlock;
	int resources[RES_MAX];
};
//maprep+++++++++++
class maprep{
public:
	//constructors------
	maprep();
	~maprep();
	//access------------
	int gXSize();
	int gYSize();
	void gSize(int &x, int &y);
	bool isClean(int x, int y, int z);
	placeable* gPlaceable(int x, int y);
	terrain* gTerrain(int x, int y);
	//Units::fleet* gFleet(int x, int y);
	//manips------------
	bool add(placeable* p);
	bool remove(placeable* p);
	void loadTerrain(string filename);
	void loadFleet(string filename);
	void loadSave(string filename);
private:
	static terrain spaceterr;
	int maxx, maxy;
	map<pair<pair<int, int>, int>, placeable*> placeMap;
};
}

#endif	/* MAPDATA_H */